Skip to content

feat: migrate the games block to xblocks-core - #316

Open
samuelallan72 wants to merge 6 commits into
openedx:mainfrom
open-craft:samuel/games-xblock
Open

samuelallan72 wants to merge 6 commits into
openedx:mainfrom
open-craft:samuel/games-xblock

Conversation

@samuelallan72

@samuelallan72 samuelallan72 commented Oct 29, 2026 •

Copy link
Copy Markdown

Description

Migrate the XBlock from https://github.com/edx/gamesxblock to this repository. In the process, split the block into "Flashcards" and "Matching" XBlocks.

Note that technically these are new xblocks, and merging the changes here will not conflict with the existing Games XBlock. However, the Games XBlock will be deprecated and eventually replaced by these new blocks. To assist in migrating existing components to the new blocks, we have written a migration guide.

Supporting information

Private-ref: https://tasks.opencraft.com/browse/BB-11332

This is being developed in tandem with openedx/frontend-app-authoring#3351

Testing instructions

cd path/to/your/tutor/devstack
git clone https://github.com/open-craft/xblocks-core
cd xblocks-core
git checkout samuel/games-xblock
cd ..

tutor mounts add ./xblocks-core
tutor dev launch -I
tutor dev exec lms -- pip install -e /mnt/xblocks-core
tutor dev exec cms -- pip install -e /mnt/xblocks-core

tutor dev stop
tutor dev start -d
  • navigate to a test course in studio
  • add "openedx_flashcards" and "openedx_matching" to the course's "Advanced Settings"
  • add some instances of the flashcards and matching blocks to the course
  • play with the editor in studio, including both game types
  • verify the editor works as expected and it saves correctly
  • save and view the student view in the live course and/or course preview
  • verify the student view works as expected
  • verify the tests pass in CI

Merge checklist:
Check off if complete or not applicable:

  • Version bumped
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Fixup commits are squashed away
  • Unit tests added/updated
  • Manual testing instructions provided
  • Noted any: Concerns, dependencies, migration issues, deadlines, tickets

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Oct 29, 2026
@openedx-webhooks

openedx-webhooks commented Oct 29, 2026 •

Copy link
Copy Markdown

Thanks for the pull request, @samuelallan72!

This repository is currently maintained by @openedx/axim-engineering.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Comment thread xblock_games/locale/config.yaml Resolved
@samuelallan72
samuelallan72 force-pushed the samuel/games-xblock branch 2 times, most recently from fbba15d to 4a9cac9 Compare October 29, 2026 04:35
Comment thread .gitignore Resolved
Comment thread xblock_games/tests/test_translations.py Resolved

@Kelketek Kelketek left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 I've given this an initial pass. I think I need to do some research before merging this in (and also double-check we're clear to on the product side.) See my comments for potential pitfalls.

I see there's a bunch of encryption machinery. It doesn't appear to actually be used. Can you verify if it's used, and if it's not, rip it and its associated tests out?

Comment thread src/xblock_flashcards/tests/settings.py Outdated
}

# Games XBlock specific settings
GAMESXBLOCK_STORAGE = None # Use default storage for tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Noting that if we have settings like this, they should use the XBLOCKS_SETTINGS convention.

We probably need to refactor this. Using an external storage breaks import/export guarantees. We may need to do this in a follow-up-- we'd need to update the frontend and backend to handle the uploads differently. The PDF block editor in frontend-app-authoring has an example of how uploads can be handled there, and we already know how we can handle uploaded images from our experience in the exemplar blocks.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kelketek Yep I figured this would be a follow up change, because it would involve deprecating the GAMESXBLOCK_STORAGE setting.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 We're no longer using this, right? Can we remove it now?

@samuelallan72

Copy link
Copy Markdown
Author

@Kelketek

I see there's a bunch of encryption machinery. It doesn't appear to actually be used. Can you verify if it's used, and if it's not, rip it and its associated tests out?

Huh it's not used. I've removed them now. Nice catch :)

@samuelallan72
samuelallan72 marked this pull request as ready for review October 30, 2026 00:33
Comment thread pyproject.toml Outdated
# 'Done' XBlocks -- ones that are ready for general use today,
# and have been migrated fully from edx-platform or their original repository.
pdf = "xblock_pdf:PDFBlock"
games = "xblock_flashcards_matching:FlashcardsMatchingXBlock"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please let me know if this entrypoint id should be updated. Leaving it at "games" will enable backward compatibility with any existing components. However, it may be confusing long-term.

We may also want a temporary id for testing, like some of the others above.

@Kelketek Kelketek Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 It should be updated, yes. A temporary ID would be fine for now, and making sure the README is updated to indicate 'In Development' status would be important here-- which it looks like you've already done.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, it looks like we'll need to do two separate IDs for two different blocks.

I'd rather we not use temporary IDs now that I think about it, since we want the frontend authoring functionality to work with the actual names we'll be using. So this will mean we need to use 'flashcards' and 'matching' as the names. That may cause conflicts with the separate 'matching' and 'flashcards' blocks we've made for WGU, but they won't be hitting this newer version of XBlocks-core for a while (it wouldn't land until Willow) so there will be lead-time to migrate. cc @pkulkark

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kelketek got it, thanks.

this will mean we need to use 'flashcards' and 'matching' as the names. That may cause conflicts with the separate 'matching' and 'flashcards' blocks we've made for WGU

These names are arbitrary though, so can we namespace them and use something like "openedx_flashcards_ and "openedx_matching"?

One concern: do we want this games block to be backwards compatible with any existing components/courses?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 Now that it's split, and the names are changed, it can't be backwards-compatible. edX will have to migrate their data or else recreate the blocks in their relevant courses. However, they would have to do so anyway, as the file storage method alone will require migration work.

We will just need to keep them posted so they know what they need to do, and how they can keep the old block alive a while longer if they need to. We're already giving them a path there by making sure the name isn't overwritten, so the old block will still work for learners until they migrate. We will have to change the authoring to recognize the new names, though, and remove the 'type' switch toggle, so those old blocks will lose editability and will be frozen.

cc @jristau1984 see above

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disappointing that we need to migrate content even before the block is fully in the core... but it appears there is nothing we can do about it, so I have no further objections.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jristau1984

need to migrate content even before the block is fully in the core

The flashcards and matching xblocks will be completely independent of the existing games xblock, so no migration is mandatory or urgent. :)

It'll be a migration at your leisure to the "new and improved" blocks. :) (correct me if I'm wrong @Kelketek )

I'll work on a migration guide. 🙂

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 Correct, though we'll probably want to remove the separate games block authoring from frontend-app-authoring, that can likely be delayed for a bit to give @jristau1984 time.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jristau1984 we've written a migration guide. :) Please let us know if you have any concerns.

@Kelketek

Kelketek commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

@samuelallan72 Per your question on the proposal, and discussion with WGU: Yes, we'd like to bifurcate the block. Do you think you'd be able to do so in this PR or would that be too much to carry in this sprint?

We will need an additional ticket for next sprint that updates frontend-app-authoring to adjust to this change. Could you create one?

@samuelallan72

Copy link
Copy Markdown
Author

@Kelketek it probably makes sense to split the block is this PR; I can do that. I can also create the ticket 👍

Comment thread xblock_flashcards/flashcards.py Resolved
Comment thread xblock_flashcards/flashcards.py Resolved
Comment thread src/xblock_matching/utils.py Resolved
Comment thread xblock_flashcards/static/README.txt Resolved
Comment thread pyproject.toml Resolved
@mphilbrick211 mphilbrick211 moved this from Needs Triage to In Eng Review in Contributions Nov 4, 2026
@Kelketek

Kelketek commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

@samuelallan72 The CI is failing, and a good part of it is untested code. Part of it is easy-to-fix lint issues, but another part is test coverage. I'm guessing a lot of the code that is uncovered is intended to be removed.

We have two options here: We could just remove the soon-to-be-dead code now and add tests for what remains even if that means a non-functional block, since it will be non-functional anyway due to lack of authoring being ready.

The other option would be to put this PR on ice until authoring is ready to go with it and merge them together. That option is probably cleaner.

In any case there are still a couple of threads talking on the product proposal, so maybe icing it is the best way. What do you think? Anything else you think we should hit before hitting pause here, if so?

@samuelallan72

Copy link
Copy Markdown
Author

@Kelketek re the missing tests, I still need to re-add tests. I removed them when I split the xblocks because of course that broke every test. I can absolutely do that, but I'm a little loath to while things are in flux still.

Agreed regarding putting it on ice until authoring is sorted out, because currently it's hard to test them without authoring. It would be nice to figure out some more simplifications and modernisations too before merging - including the obfuscation which I don't think is necessary any more, and porting more things to pydantic.

Comment thread xblock_matching/constants.py Resolved
@samuelallan72
samuelallan72 force-pushed the samuel/games-xblock branch 2 times, most recently from 00a43a1 to 13db65c Compare November 9, 2026 06:02
samuelallan72 added a commit to open-craft/frontend-app-authoring that referenced this pull request Nov 9, 2026
@farhan

farhan commented Nov 16, 2026

Copy link
Copy Markdown
Contributor

Hi @feanil, @Kelketek, @samuelallan72

I'd like to understand whether this block would be a good fit for xblocks-core. Are there any decision notes on this that could help.

@Kelketek

Copy link
Copy Markdown
Contributor

Hi @farhan !

The main product proposal for this is here. The editor for the games block is already merged into the authoring MFE, although now that it's been decided to bifurcate the games block into two separate blocks, Sam is also working on that.

@farhan

farhan commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

Thanks! for sharing details @Kelketek

@Kelketek Kelketek left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 Had a request for you to remove a setting I don't think we're using anymore, and there's also a conflict with the uv.lock. Can you take a look?

I think this is good to go. @farhan When I check backstage, there is no one other than 'Axim Engineering' listed for the maintainer here. Are you the maintainer these days? If so, it would probably be good to have you take a look. You can, of course, do so electively, too. :) Otherwise, I'm game to merge this once it's finished with my review.

@samuelallan72 Could you please prepare a document with what work @jristau1984 is likely to need to do to migrate to this when the time comes? I know he'll still be waiting for the authoring frontend to get unblocked to actually migrate, but any lead-time he can get is good, I think.

Comment thread src/xblock_matching/tests/settings.py Resolved
@samuelallan72

Copy link
Copy Markdown
Author

Thanks @Kelketek ! I'll work on re-adding some tests, and completing the matching block side of things. :)

@Kelketek

Copy link
Copy Markdown
Contributor

@samuelallan72 Gotcha. Thanks!

samuelallan72 added a commit to open-craft/frontend-app-authoring that referenced this pull request Nov 23, 2026
@samuelallan72
samuelallan72 force-pushed the samuel/games-xblock branch 2 times, most recently from 09c4195 to 739395f Compare November 23, 2026 01:24
samuelallan72 added a commit to open-craft/frontend-app-authoring that referenced this pull request Nov 23, 2026
samuelallan72 added a commit to open-craft/frontend-app-authoring that referenced this pull request Nov 23, 2026
@samuelallan72
samuelallan72 force-pushed the samuel/games-xblock branch 5 times, most recently from c138baf to 42dce03 Compare November 23, 2026 04:39

@farhan farhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have done the first pass, focused on localization.

After this PR merges, xblock_flashcards and xblock_matching also need entries in transifex.yml in openedx-translations, as openedx/openedx-translations#85196 did for #329.

Comment thread src/xblock_flashcards/flashcards.py Resolved
}

template_str = read_resource("static/html/matching.html")
template = Template(template_str)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the flashcards block: this template needs to render with the block's i18n service, or its {% trans %} strings will never be translated.

$element.find('.flashcard-front').attr('aria-hidden', 'false');
$element.find('.flashcard-back').attr('aria-hidden', 'true');
$card.attr('aria-label', getCardAriaLabel());
announce('Card ' + (currentIndex + 1) + ' of ' + totalCards + '. Term: ' + (card.front.text || ''));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These screen-reader messages are hardcoded English. Could this use the xblocks-core#336 pattern?

  • Set i18n_js_namespace = "XBlockFlashcardsI18N" on the block, so compile_xblock_translations builds a JS catalog.
  • Load the catalog with self.get_javascript_i18n_catalog_url() before this file (as Video/Problem/Annotatable do).
  • Read gettext/interpolate from window.XBlockFlashcardsI18N with a fallback to the global ones.

Also, sentences built by concatenation can't be reordered by translators. Something like interpolate(gettext('Card %(current)s of %(total)s'), {...}, true) works better.

function markMatch(a, b) {
a.addClass('matched').removeClass('selected');
b.addClass('matched').removeClass('selected');
announce('Correct match!');

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as flashcards.js: the announce() messages here (Incorrect match. Try again., Page X of Y, Congratulations! ...) need gettext/interpolate from an XBlockMatchingI18N namespace.

</div>
<div class="matching-prev-best">
<div class="matching-prev-best-subtitle">
{% trans "You completed the matching game in " %}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Splitting the sentence around the time value doesn't work for languages with a different word order (and the trailing space is part of the msgid). Could this be a single {% blocktrans %}You completed the matching game in {{ time }}{% endblocktrans %}-style string?

Comment thread src/xblock_flashcards/.tx/config Outdated
[main]
host = https://www.transifex.com

[o:open-edx:p:openedx-translations:r:xblocks-contrib-games]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points at the old xblocks-contrib resource and text.po layout. xblocks-core#329 removed the Transifex client targets, and per-block resources are now defined in openedx-translations' transifex.yml. I think this file can be dropped (xblock_pdf doesn't have one).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, dropped. :)

Comment thread src/xblock_matching/.tx/config Outdated
[main]
host = https://www.transifex.com

[o:open-edx:p:openedx-translations:r:xblocks-contrib-games]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This points at the old xblocks-contrib resource and text.po layout. xblocks-core#329 removed the Transifex client targets, and per-block resources are now defined in openedx-translations' transifex.yml. I think this file can be dropped (xblock_pdf doesn't have one).

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also dropped. :)

Comment thread src/xblock_flashcards/flashcards.py Outdated
"""

display_name = String(
default="Flashcards",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the default display name isn't marked for translation, so it shows in English in Studio and the LMS. Could it be wrapped (with the i18n service / gettext_noop pattern the other blocks use)? Same for "Matching".

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated, thanks :)

Migrate the XBlock from https://github.com/edx/gamesxblock to this
repository. In the process, split them into two separate xblocks:
matching and flashcards.

Also do some rework on the new blocks to modernise the code, remove
unused functions, etc.

Private-ref: https://tasks.opencraft.com/browse/BB-11332
@samuelallan72

samuelallan72 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

Thanks for your review @farhan , I made the requested updates. I left the student_view templates and such, because we're working on porting these to React (so the work would be immediately lost).

Note that I force pushed and squashed to resolve conflicts and rebase on the latest changes.

Please make another pass when you can! :)

Represents an image with alt text
"""

url: str

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Kelketek hmm I noticed in course exports that this url includes the domain as well - eg. "url": "http://local.openedx.io:8000/asset-v1:test+2+1+type@asset+block@How_to_Know_the_Ferns_7th_ed._p._127.jpg", which makes it no longer portable. Do you remember if you encountered this with the pdf block too? We might need to figure out how to store only the path if it's an image uploaded to assets?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 Agh, I just tried it locally with the PDF block. It does seem that this is an issue with it as well. I'm not sure what to do about this, but @bradenmacdonald may have an idea.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 Actually, I may have an idea. Maybe I can add a function to this in-progress XBlock service I'm making that can make it smart enough to translate between Studio and the LMS based on a given asset key. They both have different asset paths, so you can't just translate directly.

I'll try to get that into review tonight. cc @bradenmacdonald

@bradenmacdonald bradenmacdonald Nov 30, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, the XBlock API really should have APIs for handling file uploads and static URLs, but it never has. If you look at my new asset test course, you'll learn that each asset has many potential URLs:

Screenshot 2026-11-30 at 2 21 33 PM

Only the /static/... form is truly portable, though sometimes the other URL forms get rewritten on course import or re-runs, to keep them up to date.

What we did in the past is call the replace_urls service, and that lets you hack around some of the limitations so you can at least work with portable URLs: https://github.com/openedx/xblock-drag-and-drop-v2/blob/c14de0ef4a250852ca9a81cbb99d9b25d5ac704d/src/drag_and_drop_v2/drag_and_drop_v2.py#L1086-L1104

But what we really need is an API for attaching files to the XBlock (which is already possible in libraries and soon will be in courses too, via shadow components), an API for listing the attached files, and/or an API for a File-typed Field.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @Kelketek @bradenmacdonald ! :) I don't have time to look at this now, but I'll come back to this when I'm back from holidays.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, @bradenmacdonald . I had no idea about the ReplaceUrlsService. I guess I don't need to modify my PR to add this as it already exists.

And now I finally have an answer as to how in the world the PDF block was turning /static/path-to-pdf.pdf into an actual PDF in the rendering process-- the service isn't just used as an XBlock service. It's instantiated one-off and run on every block's fragment before sending it to the browser!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, right! You only need to call that service manually if you're handling the URLs in a handler, not if you're rendering a fragment.

@farhan farhan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samuelallan72 I am done with the next pass.

block = make_block()

# first attempt, 12 seconds
data = block.complete_matching_game(mock_handle_request("POST", {"new_time": 12})).json

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Request change: the quality check fails here and on lines 76 and 82:

E1101: Instance of 'dict' has no 'json' member (no-member)

It's a false positive (@XBlock.json_handler returns a Response), so a disable is enough:

src/xblock_matching/tests/test_matching.py:70

    data = block.complete_matching_game(mock_handle_request("POST", {"new_time": 12})).json  # pylint: disable=no-member

back: CardSide

# used by the frontend editor in Authoring
editor_open: bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A card without editor_open (e.g. from an OLX import) fails validation, so load_data returns a 500. Could it default to False?

src/xblock_flashcards/types.py:38

    editor_open: bool = False

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farhan hmm I think there are two paths here:

  1. We could leave it as-is - I don't really see the issue here regarding OLX imports. An OLX import is either an export from a working course, so it would correctly include editor_open, or it's manually constructed, in which case it's the author's responsibility to follow the expected data structures for the blocks.
  2. We just remove editor_open from the backend altogether. It felt like a fun quality of life improvement for course authors, because the expanded/collapsed status will persist. But it's not essential, and we could eventually add buttons to "expand all" and "collapse all" to help with cases with many flashcards.

What do you think?

Comment thread src/xblock_matching/matching.py Outdated
@XBlock.json_handler
def complete_matching_game(self, data, suffix=""): # pylint: disable=unused-argument
"""Complete the matching game and compare the user's time to the best_time field."""
new_time = int(data["new_time"])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

{} or "abc" gives a 500, and -5 is saved as best_time. Could it return a 400 instead?

src/xblock_matching/matching.py:124

        try:
            new_time = int(data["new_time"])
        except (KeyError, TypeError, ValueError) as err:
            raise JsonHandlerError(400, "new_time must be an integer") from err
        if new_time <= 0:
            raise JsonHandlerError(400, "new_time must be positive")

(from xblock.exceptions import JsonHandlerError)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, updated! :)

Comment thread src/xblock_matching/tests/settings.py Outdated
@@ -0,0 +1,118 @@
"""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: nothing loads these. pytest uses the root test_settings, and no other block has its own. Can they be removed?

src/xblock_flashcards/tests/settings.py
src/xblock_flashcards/tests/urls.py
src/xblock_matching/tests/settings.py
src/xblock_matching/tests/urls.py

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! I simply copied from the other blocks when I created these.

Comment thread pyproject.toml Outdated
django_find_project = false
pythonpath = [".", "src"]
addopts = "--cov src --cov-report term-missing --cov-report xml"
addopts = "--cov src --cov-report term-missing --cov-report xml --cov-report html"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These coverage changes affect every block. Could they be reverted, or explained?

  • --cov-report html (line 183)
  • dropping "*/tests/*" from omit (line 189), which counts every block's test files in coverage

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@farhan sure, I'll drop them from this PR. These would be nice to add at some point, but yeah it's a change that probably deserves it's own PR.

As for explanation: I added the html cov report so I could browse the coverage locally (the term and xml reports aren't very friendly to read. I would argue that tests should never be omitted from coverage. I've often found broken or shadowed tests by browsing the coverage. :)

Comment thread pyproject.toml Outdated
@@ -71,6 +72,9 @@ _word_cloud_extracted = "xblock_word_cloud:WordCloudBlock"
# 'Done' XBlocks -- ones that are ready for general use today,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: the new blocks sit under the 'Done' XBlocks comment, but the README marks them "In Development". Could we make it consistent?

pyproject.toml:75

# New XBlocks, still in development.
# These are prefixed to avoid conflicting with existing community blocks.
openedx_flashcards = "xblock_flashcards:FlashcardsXBlock"
openedx_matching = "xblock_matching:MatchingXBlock"

@samuelallan72

Copy link
Copy Markdown
Author

@farhan thanks for your review! I addressed and/or replied to your comments. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

open-source-contribution PR author is not from Axim or 2U

Projects

Status: In Eng Review

Development

Successfully merging this pull request may close these issues.

6 participants